<template>
  <div class='container'>
    <el-dialog
      title="预览文章"
      :visible="showPreview"
      width="800px"
      @close="cancel"
    >
      <div class="title">
        <h2>{{ previewData.title }}</h2>
        <div>
          <span>{{ previewData.createTime | parseTimeByString }}</span>
          <span>{{ previewData.username }}</span>
          <span class="el-icon-view"></span>
          <span>{{ previewData.visits }}</span>
        </div>
      </div>
      <div
        v-html="previewData.articleBody"
        class="content"
      >
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    showPreview: {
      type: Boolean,
      default: false
    },
    previewData: {
      type: Object
    }
  },
  methods: {
    cancel () {
      this.$emit('update:showPreview', false)
    }
  }
}
</script>

<style scoped lang='scss'>
.title {
  border-bottom: 1px dashed #ccc;
  padding-bottom: 10px;
  span {
    margin-left: 10px;
    margin-top: 10px;
  }
}
.content {
  background: #f5f5f5;
  padding: 10px;
}
</style>
